package com.cskaoyan.dbutils;

import com.cskaoyan.bean.Account;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 创建日期: 2022/07/28 16:42
 *
 * @author ciggar
 */
public class MyResultSetHandler implements ResultSetHandler<Account> {

    @Override
    public Account handle(ResultSet rs) throws SQLException {

        Account account = new Account();

        while (rs.next()) {

            int id = rs.getInt("id");
            String name = rs.getString("name");
            int money = rs.getInt("money");

            account.setId(id);
            account.setName(name);
            account.setMoney(money);

        }

        return account;
    }
}
